package zhuyun.code.launcheractivity.view.widget

import android.content.Context
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
import zhuyun.code.launcheractivity.R

/**
 * @author: Administrator
 * @date: 2021/11/21
 */
class MoneyTextView(val mContext:Context,val attrs:AttributeSet?,val defStyle:Int):AppCompatTextView(mContext,attrs,defStyle) {
    constructor(mContext: Context,attrs: AttributeSet?):this(mContext,attrs, 0)
    constructor(mContext: Context):this(mContext,null)
    private var drawableColor:Int = 0
    init {
        val typedArray = mContext.obtainStyledAttributes(attrs, R.styleable.MoneyTextView)
        drawableColor = typedArray.getInt(R.styleable.MoneyTextView_drawable_color,0)
        typedArray.recycle()
        var drawable: Drawable?=null
        when(drawableColor){
            1->{
                drawable = resources.getDrawable(R.drawable.icon_upoint_white)
            }
            2->{
                drawable = resources.getDrawable(R.drawable.icon_upoint_yellow)
            }
            3->{
                drawable = resources.getDrawable(R.drawable.icon_upoint_grey)
            }
        }
        drawable!!.bounds = Rect(0,0,drawable.minimumWidth,drawable.minimumHeight)
        setCompoundDrawables(drawable,null,null,null)


    }
}